package model

import (
	"newRetailByGolang/variable"
	"time"
)

type Order struct {
	Id         int64
	UserId     int64
	UserName   string
	GoodId     int64
	GoodName   string
	GoodIdList []int64 `gorm:"-"`
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func NewOrder() *Order {
	o := new(Order)
	return o
}

func (order *Order) InsertOrder(o *Order) {
	variable.Db.Create(o)
}

func (order *Order) InsertOrderByInterface(o Order) {
	variable.Db.Create(o)
}

func (order Order) InsertOrderByStruct(o *Order) {
	variable.Db.Create(o)
}

func (order Order) InsertOrderByNoPointer(o Order) {
	variable.Db.Create(o)
}

func (order *Order) Insert(o *Order) {
	variable.Db.Create(o)
}

func (order *Order) BatchInsert(os []*Order) {
	variable.Db.Create(&os)
}

func (order *Order) Delete(id int64) {
	variable.Db.Delete(order, id)
}

func (order *Order) Update(o *Order) {
	variable.Db.Save(o)
}

func (order *Order) BatchDelete(relation string, id int64) {
	variable.Db.Where(relation+" = ?", id).Delete(order)
}

type FileInfo struct {
	Name        string
	IsDir       bool
	ModTime     time.Time
	Size        int64
	SubFileInfo []*FileInfo
	Details     string
}
